package pcvc.common.classes;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

public class StudentAnswer implements Serializable
{

    /**
     * Whether the answer is correct or not
     */
    private boolean correct;

    /**
     * The student id of the given answer
     */
    private int studentId;

    /**
     * The variables given by the students that helps solve the equation
     */
    private Map<String, String> variables;

    /**
     * Create a new answer
     */
    public StudentAnswer( )
    {
        correct = false;
        variables = new LinkedHashMap<String, String>( );
    }

    /**
     * Adds a new variable to be tested in the equation
     * @param expression The expression of the variable
     * @param variable The variable itself
     */
    public void addVariable( String variable, String expression )
    {
        variables.put( variable, expression );
    }

    public boolean isCorrect( )
    {
        return correct;
    }

    public void setCorrect( boolean correct )
    {
        this.correct = correct;
    }

    public int getStudentId( )
    {
        return studentId;
    }

    public void setStudentId( int studentId )
    {
        this.studentId = studentId;
    }

    public Map<String, String> getVariables( )
    {
        return variables;
    }

    public void setVariables( Map<String, String> variables )
    {
        this.variables = variables;
    }
    
    public String toString()
    {
    	String cor = "Incorrect";
    	
    	if(correct)
    	{
    		cor = "Correct";
    	}
    	
    	return "Student "+studentId+ ", his ask was "+cor;
    }
}